<?php

/**
 * SmsLogModel 模型
 * Class SmsLogModel
 */
class SmsLogModel extends BaseModel
{

    public $tableName = "sms_log";
    public $errMsg = '';

    public static $typeArr = [
        'reg'   => '注册',
        'findpwd'   => '重置登录密码',
        'findpwd_pay'   => '重置支付密码',
        'edit_moble'    => '修改手机号'
    ];

    static private $_singleton;

    public function __construct()
    {
        parent::__construct($this->tableName);
    }

    static public function getSingleton()
    {
        if (!self::$_singleton) {
            self::$_singleton = new static();
        }

        return self::$_singleton;
    }

    public function add($data)
    {
        try {
            $selfModel = static::getSingleton();
            return $selfModel->insert([
                'moble'     => $data['moble'],
                'code'      => $data['code'],
                'type'      => $data['type'],
                'content'   => $data['content'],
                'status'    => 1,
                'created_at'    => time()
            ]);
        } catch (Exception $e) {
            $this->errMsg = $e->getMessage();
            return false;
        }
    }
}